<!DOCTYPE html>
<html>
<head>
    <title>菜单添加</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <!-- 所有的 css & js 资源 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../../../static/sa.css">
    <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
    <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
    <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
    <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
    <script src="../../../static/sa.js"></script>
</head>
<body>
<div class="vue-box" style="display: none;" :style="'display: block;'">
    <!-- 参数栏 -->
    <div class="c-panel">
        <div class="c-title">菜单添加</div>
        <el-form v-if="m">
            <div class="c-item br">
                <label class="c-label">菜单名称：</label>
                <el-input v-model="m.menuName"></el-input>
            </div>
            <div class="c-item br">
                <label class="c-label">类型：</label>
                <el-select v-model="m.type">
                    <el-option label="目录" :value="0"></el-option>
                    <el-option label="菜单" :value="1"></el-option>
                    <el-option label="按钮" :value="2"></el-option>
                </el-select>
            </div>
            <div class="c-item br">
                <label class="c-label">父级菜单 ：</label>
                <el-select v-model="m.parentId" @focus="getChoiceList">
                    <el-option label="一级菜单" :value="0"></el-option>
                    <el-option
                            v-for="item in options"
                            :key="item.id"
                            :label="item.menuName"
                            :value="item.id">
                    </el-option>
                </el-select>
            </div>
            <div class="c-item br">
                <label class="c-label">url：</label>
                <el-input v-model="m.url"></el-input>
            </div>
            <div class="c-item br">
                <label class="c-label">菜单排序：</label>
                <el-input v-model="m.menuOrder"></el-input>
            </div>

            <div class="c-item br">
                <label class="c-label">授权标识符：</label>
                <el-input v-model="m.permission"></el-input>
            </div>
            <div class="c-item br">
                <label class="c-label"></label>
                <el-button type="primary" icon="el-icon-plus" @click="ok">确定</el-button>
            </div>
        </el-form>
    </div>
</div>
<script type="text/javascript">
    new Vue({
        el: '.vue-box',
        data: {
            m: {	// 查询参数
                menuName: '',
                menuOrder: '',
                type: '',
                url:'',
                permission: '',
                parentId: ''
            },
            options:[]
        },
        methods: {
            getChoiceList: function(){
                sa.ajax('/api/system/v1/getList',null,function (res){
                    this.options=res.data;
                }.bind(this));
            },

            // ok
            ok: function() {
                sa.ajax('/api/system/v1/addMenu',this.m, function(res) {
                    sa.alert('菜单添加成功');
                    setTimeout(sa.f5,3000);
                }.bind(this))
            }
        }
    })
</script>
</body>
</html>
